/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.mzk.lidovky.articles.articleImport;

import java.util.Set;

/**
 *
 * @author Martin Řehánek (rehan@mzk.cz)
 */
public class ArticleImport {

    private String articlePid;
    private ArticleXml articleXml;
    private Set<String> volumePids;
    private Set<String> issuePids;
    private Set<String> pagePids;
    private String description; //for logging

    /**
     *
     * @param articleUuid generated UUID for article
     * @param articleXml generated ArticleXml (that has been initalized with same PID as $articlePid)
     * @param description brief description of article (just for logging the import)
     * @param volumePids Set of PIDs of periodical volumes that contain the article (usually just single volume)
     * @param issuePids Set of PIDs of periodical issues that contain the article
     * @param pagePids Set of PIDs of pages that the article is printed on
     */
    public ArticleImport(String articleUuid, ArticleXml articleXml, String description, Set<String> volumePids, Set<String> issuePids, Set<String> pagePids) {
        this.articlePid = "uuid:".concat(articleUuid);
        this.articleXml = articleXml;
        this.description = description;
        this.volumePids = volumePids;
        this.issuePids = issuePids;
        this.pagePids = pagePids;
    }

    /**
     * @return list of pids of volumes (periodicalVolume) that contain the article
     */
    public Set<String> getVolumePids() {
        return volumePids;
    }

    /**
     * @return list of pids of issues (periodicalItem) that contain the article
     */
    public Set<String> getIssuePids() {
        return issuePids;
    }

    /**
     * @return list of pids of the pages that contain the article
     */
    public Set<String> getPagePids() {
        return pagePids;
    }

    /**
     * @return articleXml
     */
    public ArticleXml getArticleXml() {
        return articleXml;
    }

    /**
     * @return pid of new article
     */
    public String getArticlePid() {
        return articlePid;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("articlePid: '");
        builder.append(articlePid);
        builder.append("'\n");
        builder.append("PIDs of pages on which article is placed: ");
        builder.append('\n');
        for (String pid : pagePids) {
            builder.append(pid);
            builder.append('\n');
        }
        builder.append("PIDs of volumes that contain article:");
        builder.append('\n');
        for (String pid : volumePids) {
            builder.append(pid);
            builder.append('\n');
        }
        builder.append("PIDs of issues that contain article:");
        builder.append('\n');
        for (String pid : issuePids) {
            builder.append(pid);
            builder.append('\n');
        }
        return builder.toString();
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }
}
